home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJSRC111.ZIP / go32 / npx.asm < prev    next >
Assembly Source File  |  1993-11-12  |  2KB  |  130 lines

  1. ; This is file NPX.ASM
  2. ;
  3. ; Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. ;    History:69,29
  16.     title    tables
  17.     .386p
  18.  
  19.     include    segdefs.inc
  20.     include tss.inc
  21.     include gdt.inc
  22.     include idt.inc
  23.  
  24. ;------------------------------------------------------------------------
  25.  
  26.     start_data16
  27.  
  28.     extrn    ivec_number:byte
  29.     extrn    _screen_seg:word
  30.  
  31. temp87    dw    1 dup (?)
  32.  
  33.     end_data16
  34.  
  35. ;------------------------------------------------------------------------
  36.  
  37.     start_code16
  38.  
  39. ;------------------------------------------------------------------------
  40.  
  41.     public    _detect_80387        ; direct from the Intel manual
  42. _detect_80387:                ; returns 1 if 387, else 0
  43.     push    si
  44.     fninit
  45.     mov    si,offset dgroup:temp87
  46.     mov    word ptr [si],5a5ah
  47.     fnstsw    [si]
  48.     cmp    byte ptr [si],0
  49.     jne    no_387
  50.  
  51.     fnstcw    [si]
  52.     mov    ax,[si]
  53.     and    ax,103fh
  54.     cmp    ax,3fh
  55.     jne    no_387
  56.  
  57.     fld1
  58.     fldz
  59.     fdiv
  60.     fld    st
  61.     fchs
  62.     fcompp
  63.     fstsw    [si]
  64.     mov    ax,[si]
  65.     sahf
  66.     je    no_387
  67.     fninit            ; 387 present, initialize.
  68.     fnstcw    temp87
  69.     wait
  70.     and    temp87,0fffah    ; enable invalid operation exception
  71.     fldcw    temp87
  72.     mov    ax,1
  73.     pop    si
  74.     ret
  75.  
  76. no_387:
  77.     mov    ax,0
  78.     pop    si
  79.     ret
  80.  
  81. ;------------------------------------------------------------------------
  82.  
  83.     public    _ivec7
  84. _ivec7:
  85.     push    eax
  86.     mov    eax,cr0
  87.     and    eax,0FFFFFFF3h
  88.     mov    cr0,eax
  89.     pop    eax
  90.     iretd
  91.  
  92.     public    _ivec75
  93. _ivec75:
  94.     push    ax
  95.     push    ds
  96.  
  97.     push    g_rdata
  98.     pop    ds
  99.     mov    ivec_number,75h
  100.  
  101. ; bug here - assumed color monitor; should load screen_seg*16+4; not tested
  102. ;    push    g_core
  103. ;    pop    ds
  104. ;    inc    word ptr ds:[0b8004h]        ;old
  105.  
  106.     xor    ax,ax
  107.     out    0f0h,al
  108.     mov    al,20h
  109.     out    0a0h,al
  110.     out    20h,al
  111.  
  112.     pop    ds
  113.     pop    ax
  114.     db    0eah
  115.     dw    0, g_itss
  116.  
  117. ;------------------------------------------------------------------------
  118.  
  119.     end_code16
  120.  
  121. ;------------------------------------------------------------------------
  122.  
  123.     start_code32
  124.  
  125.     end_code32
  126.  
  127. ;------------------------------------------------------------------------
  128.  
  129.     end
  130.